package com.fanfanwang.ffw.app.adapter;

import java.util.ArrayList;

import com.fanfanwang.ffw.app.R;
import com.fanfanwang.ffw.app.bean.RemindTimeBean;
import com.fanfanwang.ffw.app.bean.ServiceBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class RemindTimeListAdapter extends BaseAdapter {

	private ArrayList<String> beans;
	private Context mContext;
	private int pos;//表示默认那个倒计时时间被选中
	public RemindTimeListAdapter(Context mContext,ArrayList<String> beans,int pos) {
		// TODO Auto-generated constructor stub
		this.mContext = mContext;
		this.beans = beans;
		this.pos=pos;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder holder;
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.item_for_remind_timelist, null);
			holder = new ViewHolder();
			holder.remindtime_title = (TextView) convertView.findViewById(R.id.tv_remindtime);
			holder.imageView = (ImageView) convertView.findViewById(R.id.iv_remindtime);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		if(beans!=null&&position<beans.size())
		{
			holder.remindtime_title.setText(beans.get(position));
		}
		if(pos==position)
		{holder.imageView.setImageResource(R.drawable.radio_select);
		}else{
			holder.imageView.setImageResource(R.drawable.radio_unselect);
		}
		return convertView;
	}
	class ViewHolder {
		public 	TextView remindtime_title;
		public 	ImageView imageView;
	}

}
